package com.example.graalvm21.utils.common;


import com.example.graalvm21.model.constants.DateConstants;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>工具类-时间</p>
 *
 * @author wz
 *
 * @date 2025/10/27 9:29
 *
 * @version 1.0
 */
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {

    public static String getDate() {
        return getDate(new Date(), DateConstants.YYYY_MM_DD);
    }

    public static String getDate(String format) {
        return getDate(new Date(), format);
    }

    public static Date getDate(String date, String format) {
        try {
            return new SimpleDateFormat(format).parse(date);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static String getDate(Date date, String format) {
        return new SimpleDateFormat(format).format(date);
    }

    public static String dateTime() {
        return getDate(new Date(), DateConstants.YYYY_MM_DD_HH_MM_SS);
    }

    public static String datePath() {
        return getDate(DateConstants.YYYYMMDD);
    }

    public static boolean transverseDate(String str) {
        String pattern = "\\d{4}-\\d{2}-\\d{2}";
        return str.matches(pattern);
    }


}